package com.hgkj.system.async.task;

import cn.dev33.satoken.stp.StpUtil;
import com.hgkj.common.async.template.AsyncTask;
import lombok.extern.slf4j.Slf4j;

/**
 * 异步任务 强制下线
 */
@Slf4j
public class ForcedOfflineAsyncTask implements AsyncTask {

    private final Long userId;

    public ForcedOfflineAsyncTask(Long userId) {
        this.userId = userId;
    }

    @Override
    public void execute() {
        log.info("[开始执行强制下线异步任务,userId:{}]", userId);
        try {
            StpUtil.kickout(userId);
        } catch (Exception e) {
            log.error("[强制下线失败：{}]", e.getMessage());
        }
        log.info("[强制下线成功，记录操作日志]");
    }
}
